package com.gz2;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;

public class Test2 {
    public static void main(String[] args) {
        outputiostream_();
    }

    public static void outputiostream_() {
        String filepath="E:\\Java\\java_code\\test\\lianxi2.txt";
        FileWriter filewriter=null;
        String s="风雨之后，定见彩虹";
//        char [] buffer=s.toCharArray();

        try {
            filewriter=new FileWriter(filepath);
            filewriter.write(s);//可以String，也可以char[]，char,int等
            System.out.println("写入成功");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if( filewriter!=null)
                    filewriter.close();//一定要写，否则最后不会录入！
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
